package app.kotlin_1

/**
 * Created by 刘智强 on 2017/10/12.
 */
fun main(args: Array<String>) {

//    val sum=fun Int.(other:Int)=this+other
    val sum={x:Int,y:Int -> x+y}
    println(sum(2,4))
    fun operate(x:Int=0,y:Int=0,body:(Int,Int)->Int){//body是一个函数类型，传入两个Int类型参数，返回一个Int类型参数
        print("this result is "+body(x,y))
    }


}

class  TestInstance private  constructor(){
    /**
     * l懒汉式 单例模式
     */
    companion object {
         val instance:TestInstance by lazy { TestInstance() }
    }
}
